import { NextRequest } from "next/server";


export async function POST(request: NextRequest) {
    // const {session_id} = await request.json();
    const session_id = request.nextUrl.searchParams.get('session_id');
    const {id,jsonrpc,method,params} = await request.json();
    const url = new URL(request.url);
    url.host = 'localhost:8000';
    url.protocol = 'http:';
    url.pathname = '/messages';

    return fetch(url + '?session_id=' + session_id, {
        method: 'POST',
        headers: request.headers,
        body: JSON.stringify({
            id,
            jsonrpc,
            method,
            params
        })
    });
}